//2009/08/25 00:18:07
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class ChainOfRectangles
{
public:
    int getMaximalArea(vector <int> width, vector <int> height, string color)
    {
		int red = 0;
		int blue = 0;
		int green = 0;
		int prearea = 0;
		for(int i=color.size()-1; i>=0; i--)
		{
			if(color[i] == 'R') red += width[i] * height[i] - prearea;
			if(color[i] == 'B') blue += width[i] * height[i] - prearea;
			if(color[i] == 'G') green += width[i] * height[i] - prearea;
			prearea = width[i] * height[i];
		}
		return max(red, max(blue, green));
    }
};
